#include "Wall.h"

#include "InputHandler.h"
#include "Utility.h"
#include "GameGlobals.h"
#include "Resources.h"

LINKCLASSTONAME("ent_wall", Wall);

Wall::Wall(sf::RenderWindow *App) : BaseMoveable(App)
{
	DrawOrder = 1;

	sf::Vector2f Points[4];
	float height, width;
	height = Util::Random(50,200);
	width = Util::Random(50,200);
	height = 128;
	width = 64;
	Points[0] = sf::Vector2f(-width / 2,height / 2);
	Points[1] = sf::Vector2f(width / 2, height / 2);
	Points[2] = sf::Vector2f(width / 2, -height / 2);
	Points[3] = sf::Vector2f(-width / 2, -height / 2);

	CreatePhysics();
	GetPhysicsObject()->PhysicsInitPolygon(this, Points, 4);
	GetPhysicsObject()->SetMass(1000);
	GetPhysicsObject()->SetMoveable(false);

	sf::Vector2<float> Pos = Util::VecRand(-2000,2000);
	GetPhysicsObject()->SetPos(Pos);
	SetPos(Pos);

	shpHull.SetTexture(*Resources::Instance()->RequestImage("ConcreteWall", true));
	shpHull.Resize(128,128);
	shpHull.SetOrigin(128,128);
	shpHull.SetPosition(GetSFMLPos());
}

Wall::~Wall(void)
{

}

void Wall::OnCollide(BaseMoveable *ent1, BaseMoveable *ent2, CollisionData CollideInfo)
{
}

void Wall::Think()
{
}

void Wall::Draw()
{
	shpHull.SetPosition(GetSFMLPos());
	shpHull.SetRotation(GetAngle());
	pRender->Draw(shpHull);
	GetPhysicsObject()->Draw();
}